package com.lsh.dao;

import com.lsh.domain.UserDatum;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;
import org.springframework.stereotype.Repository;

import java.util.Map;

/**
 * 用户基本信息dao类（用户基本信息实体类）
 */
@Repository
public interface UserDatumDao {

    //注册创建user_informations表
    @Insert("insert into user_informations (uid, nickname, sex, birthday, position)" +
            " values (#{uid}, #{nickname}, #{sex}, #{birthday}, #{position})")
    void saveByUserDatum(UserDatum userDatum);

    // 获取用户基本信息(根据uid查询user_informations表)
    @Select("select * from user_informations where uid = #{userId}")
    UserDatum getByUserId(int userId);

    // 获取用户基本信息(根据uid查询user_informations表)
    @Select("select nickname from user_informations where uid = #{userId}")
    String getNickname(int userId);

    //修改用户基本信息
    @Update("update user_informations set " +
            "nickname=#{nickname}, sex=#{sex}, birthday=#{birthday}, address=#{address}, position=#{position}, intro=#{intro} " +
            "where uid = #{uid}")
    int updateUserDatum(UserDatum userDatum);

    //修改用户备注信息
    @Update("update user_informations set remark=#{remark} where uid = #{uid}")
    int updateRemark(@Param("remark") String remark, @Param("uid") String userId);

}
